#include <cstdlib>
#include <iostream>

#include "grid.h"

//global constants
long G_SEED = 1531;  //global seed for random number generator

using namespace std;

int main(int argc, char *argv[])
{
    // Get command line input
	char* netlist_file = "";
	if(argc == 1) {
		cerr << "Command Line Required: " << argv[0] << " netlist_file"<< endl;
		exit(0);
	}
	else {
		netlist_file = argv[1];
	}
	
	srand(G_SEED);
	
	Grid grid_test(netlist_file);
	cerr << endl << "Placement:" << endl;
	grid_test.place();

	cerr << "Total Cost: " << grid_test.totalCost << endl;
	cerr << "Total Feedthrough Cells: " << grid_test.totalFeedthrough << endl;
	cerr << "Feedthrough Nets in List: " << grid_test.feedthroughList.size() << endl;
	cerr << "Square Side: " << grid_test.squareSide << endl;
	cerr << "Feedbacks by Row: ";
	for(unsigned short int l = 0; l < grid_test.feedthrough.size(); l++) {
		cerr << grid_test.feedthrough[l] << ",";
	}
	cerr << endl;
	cerr << "Max Feedthrough: " << grid_test.maxFeedthrough << endl;

	cerr << endl << "Router:" << endl;
	grid_test.route();
	cerr << "Printing Magic File..." << endl;
	grid_test.printMag();
//	grid_test.prettyPrintGrid();
//	grid_test.prettyPrintRouteGrid();
//	grid_test.prettyPrintRouteChannel();
	
}
